//
//  JLastView.m
//  HeadIndustry
//
//  Created by jun on 2017/8/30.
//  Copyright © 2017年 jun. All rights reserved.
//

#import "JLastView.h"

@implementation JLastView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        self.opaque = NO;
        self.backgroundColor = [UIColor whiteColor];
        [self setUpView];
    }
    return self;
}

- (void)setUpView {
    
    _nameLabel = [YYLabel new];
    _nameLabel.top = 5;
    _nameLabel.left = 0;
    _nameLabel.size = CGSizeMake(kWindowW , 50);
    _nameLabel.font = kFONT_TITLE(24);
    _nameLabel.textColor = [UIColor blackColor];
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    _nameLabel.numberOfLines = 0;
    [self addSubview:_nameLabel];
    
    CALayer *line = [CALayer layer];
    line.top = _nameLabel.bottom - 1;
    line.centerX = _nameLabel.centerX - 40;
    line.size = CGSizeMake(80, 1);
    line.backgroundColor = kRGBColor(157, 157, 157).CGColor;
    [self.layer addSublayer:line];
    
    _StoreProductCountLabel = [YYLabel new];
    _StoreProductCountLabel.top = line.bottom;
    _StoreProductCountLabel.left = 0;
    _StoreProductCountLabel.size = CGSizeMake(kWindowW/2.0 - 10, 50);
    _StoreProductCountLabel.font = kFONT_TITLE(16);
    _StoreProductCountLabel.textColor = kRGBColor(150, 150, 150);
    _StoreProductCountLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:_StoreProductCountLabel];
    
    _CollectCountLabel = [YYLabel new];
    _CollectCountLabel.top = line.bottom;
    _CollectCountLabel.left = kWindowW/2.0 +10;
    _CollectCountLabel.size = CGSizeMake(kWindowW/2.0 - 10 , 50);
    _CollectCountLabel.font = kFONT_TITLE(16);
    _CollectCountLabel.textColor = kRGBColor(150, 150, 150);
    _CollectCountLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:_CollectCountLabel];

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.top = _CollectCountLabel.bottom + 5;
    btn.centerX = _nameLabel.centerX - 60;
    btn.size = CGSizeMake(120, 40);
    [btn setTitle:@"进入店铺" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    btn.layer.borderWidth = 0.5;
    btn.layer.borderColor = [UIColor redColor].CGColor;
    [btn addTarget:self action:@selector(inputStoreBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn];
}

- (void)setProductModel:(JProductDetailModel *)productModel
{
    _productModel = productModel;
    _nameLabel.text = productModel.VendorName;
    _StoreProductCountLabel.text = [NSString stringWithFormat:@"单品    %ld",(long)productModel.StoreProductCount];
    _CollectCountLabel.text = [NSString stringWithFormat:@"粉丝    %ld",(long)productModel.CollectCount];
}

- (void)inputStoreBtnClick:(UIButton *)btn
{
    if (_inputStore) {
        _inputStore();
    }
}


@end
